package scaladuct

import java.lang.annotation.{Annotation}

/**
 * <p>
 * Created by IntelliJ IDEA.
 * User: zslajchrt
 * Date: Aug 11, 2010
 * Time: 5:04:05 PM
 */

object Utils {
  def findAnnotation[A <: Annotation](paramAnnotations: Array[Annotation], annotClass: Class[A]): Option[A] = {
    paramAnnotations.find(annot => {
      annot.annotationType == annotClass
    }).asInstanceOf[Option[A]]
  }

  def findAnnotation[A <: Annotation, B <: Annotation](paramAnnotations: Array[Annotation],
                                                       annotClassA: Class[A],
                                                       annotClassB: Class[B]): (Option[A], Option[B]) = {
    (findAnnotation[A](paramAnnotations, annotClassA), findAnnotation[B](paramAnnotations, annotClassB))
  }

}